home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / themous.com / THEMOUSE.DOC < prev    next >
Encoding:
Text File  |  1991-01-02  |  16.4 KB  |  368 lines

  1.  
  2.  
  3.  
  4.                          TheMouse For Turbo Pascal!
  5.                        Units for Turbo Pascal 4 and 5
  6.  
  7.  
  8.  
  9.                                Kevin A. Kwast
  10.                                P.O. Box 1397
  11.                                Coppell, Texas
  12.                                         75019
  13.  
  14.  
  15.                          $10 Shareware Registration
  16.  
  17.  
  18.  
  19.                                DOCUMENTATION
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.     TheMouse is a collection of routines for accessing a Microsoft or
  28. compatible mouse from Turbo Pascal.  You can now easily include mouse
  29. support to your programs with these 12 simple routines, which access the
  30. 14 most common functions provided by interrupt 33h.
  31.  
  32.     Requirements:   Turbo Pascal 4.0 or higher.
  33.  
  34.     All of the routines are in a unit, which must be included in your program's
  35. USES statement to make the procedures available to your program.  For detailed
  36. information on units, see your Turbo Pascal manual.
  37.  
  38.     Users of Turbo Pascal 4 or 5.0 should use the TMOUSE4 unit, and users of
  39. version 5.5 should use TMOUSE5.  The source code in these units is IDENTICAL,
  40. except that version 4 and 5.0 units are not compatible with version 5.5, and
  41. vice versa.
  42.  
  43.     For example:
  44.  
  45.            Uses Crt, Dos, TMouse4;
  46.  
  47.  
  48.     Most of these routines work identically whether you are in text or in
  49. graphics mode, but the coordinate system does differ.  In text mode, the
  50. screen's resolution is 640x200 (the same as CGA's high resolution).  To
  51. determine the text cursor position, divide the location by 8.
  52.  
  53.     In graphics mode, the screen's resolution is determined by what graphics
  54. mode and driver you are in.
  55.  
  56.  
  57.     This is the Interface section of the units:
  58.  
  59.     Type TheMouseInitType = Record
  60.                               Exists: Boolean;
  61.                               Buttons: Integer;
  62.                                     { Bit 0: Left Button }
  63.                                     { Bit 1: Right Button }
  64.                                     { Bit 2: Middle Button, if present }
  65.                             End;
  66.  
  67.          TheMouseInfoType = Record
  68.                               ButtonStatus,
  69.                               ButtonCount,
  70.                               Column,
  71.                               Row: Integer;
  72.                             End;
  73.  
  74.          TheMouseEventType = Record               {For Event Trapping}
  75.                                EventMask,
  76.                                ButtonStatus,
  77.                                Column,
  78.                                Row: Word;
  79.                              End;
  80.  
  81.  
  82.     Var TheMouseCursorStatus: Integer;
  83.  
  84.     Procedure tmReset(var TheMouseInit: TheMouseInitType);
  85.     Procedure tmCursor(Show: Boolean);
  86.     Procedure tmPos(var TheMouseInfo: TheMouseInfoType);
  87.     Procedure tmMoveTo(Col, Row: Integer);
  88.     Procedure tmPressed(Button: Integer; var TheMouseInfo: TheMouseInfoType);
  89.     Procedure tmReleased(Button: Integer; var TheMouseInfo: TheMouseInfoType);
  90.     Procedure tmColRange(Min, Max: Integer);
  91.     Procedure tmRowRange(Min, Max: Integer);
  92.     Procedure tmGraphCursor(HHot, VHot: Integer; MaskSeg, MaskOfs: Word);
  93.     Procedure tmTextCursor(CursorType, Arg1, Arg2: Word);
  94.     Procedure tmTask(Mask, TaskSeg, TaskOfs: Word);
  95.     Procedure tmPen(Pen: Boolean);
  96.  
  97.  
  98.     Here are detailed descriptions of the three types, one variable, and ten
  99. procedures available in the units:
  100.  
  101.  
  102.     Type TheMouseInitType          Used By: tmReset
  103.  
  104.        This type returns information about the mouse, such as whether one is
  105.        available, and how many buttons it has.
  106.  
  107.     Type TheMouseInfoType          Used By: tmPos, tmPressed, tmRelease
  108.  
  109.        This type returns information about the mouse and the buttons on
  110.        the mouse.
  111.  
  112.     Type TheMouseEventType         Not Used by Any of the Routines
  113.  
  114.        This type is not used by the routines in TheMouse.  It has been provided
  115.        for your convenience in writing event handlers for tmTask.  See the
  116.        example event handler in MouseMenu for more information.
  117.  
  118.     Var TheMouseCursorStatus: Integer
  119.  
  120.        The mouse routines update this variable, since there is no way to
  121.        ask the mouse driver whether the mouse cursor is turned on or off.
  122.        When you use tmReset, this variable is set to -1 (cursor off).  When
  123.        you use tmCursor to turn the cursor on, it sets TheMouseCursorStatus
  124.        to zero.  When you use tmCursor(False) to turn the mouse cursor off,
  125.        TheMouseCursorStatus is set back to -1.  Thus, you can check this
  126.        variable, and if TheMouseCursorStatus is zero, the cursor is on. If
  127.        TheMouseCursorStatus is -1, then the cursor is off.  This is the
  128.        method used internally by the Mouse Driver, except that the Mouse
  129.        Driver allows you to sink into several layers of cursor off, requiring
  130.        you to use "cursor on" several times to turn the cursor back on.  This
  131.        unit is intelligent enough to keep that from happening, so you can
  132.        be assured that when you say tmCursor(True), the cursor really is
  133.        on.  DO NOT CHANGE THIS VARIABLE YOURSELF!
  134.  
  135.  
  136.     Procedure tmReset(var TheMouseInitType);       Function 0
  137.  
  138.        Use tmReset at the beginning and the end of your program.  This will
  139.        initialize the mouse, place the mouse cursor in the center of the
  140.        screen, turn the mouse cursor off, and set the mouse's range to the
  141.        full screen.  This procedure returns the existence of a mouse, and the
  142.        number of buttons.
  143.  
  144.           Exists: Boolean    TRUE is a mouse is installed, FALSE otherwise
  145.           Buttons: Integer   The number of buttons on the mouse (2 or 3)
  146.  
  147.  
  148.     Procedure tmCursor(Cursor: Boolean);                  Functions 1 and 2
  149.  
  150.        If you specify tmCursor(True), the mouse cursor is turned on.  If you
  151.        specify tmCursor(False), the mouse cursor is turned off.  The status
  152.        variable (TheMouseCursorStatus) is always adjusted accordingly.
  153.        When the cursor is in text mode, it stores the character at the
  154.        position the cursor is on. When the cursor leaves that position, or
  155.        is turned off, the original character and attribute are restored. This
  156.        makes a lot of sense, but it can cause one problem.  If you write
  157.        something at the mouse cursor's current location, it is replaced by
  158.        the mouse driver when the cursor leaves that spot.  If this is hard
  159.        to understand, see the DoDemo procedure in the MouseText example.
  160.  
  161.  
  162.     Procedure tmPos(var M: TheMouseInfoType);                    Function 3
  163.  
  164.        This procedure returns information about the current status of the
  165.        mouse.  It returns the current location of the mouse, and the
  166.        status of the mouse buttons.  This function is not as useful as some
  167.        of the others, because it requires that you check it constantly.
  168.        See the example mouse graphics program, MouseDraw, for an example of
  169.        the function in use.
  170.  
  171.           ButtonStatus: Returns which buttons are currently pressed
  172.           Column: The Column Location (X) of the Mouse
  173.           Row: The Row Location (Y) of the Mouse
  174.  
  175.  
  176.     Procedure tmMoveTo(Column, Row: Integer);                    Function 4
  177.  
  178.        This procedure moves the mouse cursor to a specified position.
  179.  
  180.  
  181.     Procedure tmPressed(B: Integer; var M: TheMouseInfoType);    Function 5
  182.  
  183.        This procedure returns information about how many times the button
  184.        specified in B (0 = left; 1 = right; 2 = middle) has been pressed.
  185.        Getting this information clears it from the mouse device driver, so
  186.        this procedure returns information about what has happened since the
  187.        last call to tmPressed.  One warning about using tmPressed:  If it is
  188.        checked in a loop, the loop might check the procedure several times
  189.        while the button is held down, but each check would return that same
  190.        click as if it were a new one.
  191.  
  192.           ButtonStatus: The current status of the buttons, as in tmPos.
  193.           ButtonCount: The number of times button B has been pressed.
  194.           Column, Row: The position of the mouse THE LAST TIME BUTTON B WAS
  195.                        PRESSED.  If it is currently pressed, the current
  196.                        position is returned.
  197.  
  198.  
  199.     Procedure tmReleased(B: Integer; var M: TheMouseInfoType);   Function 6
  200.  
  201.        This procedure returns information about how many times the button
  202.        specified in B (0 = left; 1 = right; 2 = middle) has been released.
  203.        Similar to tmPressed, calling this procedure clears the information
  204.        from the mouse device driver, so information is relative to the last
  205.        call to tmReleased.  This is a better way to check the mouse than
  206.        tmPressed, since a button being released only happens once each click.
  207.  
  208.           ButtonStatus: The current status of the buttons, as in tmPos.
  209.           ButtonCount: The number of times button B has been released.
  210.           Column, Row: The position of the mouse the last time button B
  211.                        was released.
  212.  
  213.  
  214.     Procedure tmColRange(Min, Max: Integer);                     Function 7
  215.  
  216.        This procedure sets the columns in which the mouse cursor can travel.
  217.        The mouse cursor will refuse to leave the area you confine it to.
  218.  
  219.     Procedure tmRowRange(Min, Max: Integer);                     Function 8
  220.  
  221.        Similar to tmColRange, this procedure sets the rows for the cursor.
  222.        See the example program, MouseMenu, for an example of how this can
  223.        be very useful.
  224.  
  225.  
  226.     Procedure tmGraphCursor(hHot, vHot: Integer; maskSeg, maskOfs: Word);
  227.                                                                  Function 9
  228.  
  229.        This sets the graphics cursor from the default northwest-pointing
  230.        arrow to any cursor you want.  Please see the example graphics program,
  231.        MouseDraw, for information and routines pertaining to the graphics
  232.        cursor.
  233.  
  234.  
  235.     Procedure tmTextCursor(CursorType, Arg1, Arg2: word);        Function 10
  236.  
  237.        There are two types of cursors in text mode, the video adapter's cursor
  238.        (a "hardware" cursor) and the mouse driver's cursor.  CursorType 1 puts
  239.        the hardware cursor under your control, although the location for the
  240.        text I/O does not change.  CursorType 0 creates a seperate mouse cursor,
  241.        leaving the hardware cursor to act normally.  In addition, the mouse
  242.        driver's cursor can be customized, making it appear like any of the
  243.        256 IBM ASCII characters.  The mouse driver cursor (type 0) is the
  244.        default, and it's appearance defaults to a full block (ASCII 219) that
  245.        inverts the attribute of the character it is on.  Also, unlike the
  246.        hardware cursor, the mouse driver's cursor does not blink.
  247.  
  248.         Arg1 and Arg2 control the appearance of the cursor.
  249.           -- Arg1 is the screen mask.  Use $77FF for the see-through
  250.              rectangle and 0 for one of the IBM ASCII characters.
  251.           -- Arg2 defines the cursor itself.  Put the attribute byte for
  252.              the cursor in the upper byte of the word, and place the ASCII
  253.              value for the character in the lower byte.  Use 0 for the
  254.              rectangle.
  255.  
  256.         The hardware cursor's appearance can be modified somewhat.  Use
  257.         Arg1 to define the top scan line (which is always 0), and put the
  258.         bottom scan line in Arg2.  (On monochrome systems, the bottom scan
  259.         line is 12.  On systems with graphics boards [CGA,EGA,etc.] operating
  260.         in text mode, the bottom scan line is 7)
  261.  
  262.  
  263.     Procedure tmTask(Mask, TaskSeg, TaskOfs: Word);              Function 12
  264.  
  265.        This is one of the most powerful procedures in TheMouse.  It keeps you
  266.        from having to constantly scan the mouse in much the same way the ringer
  267.        on a telephone keeps you from having to keep picking up the phone to see
  268.        if anyone is there.  tmTask attaches one of your routines (a task) to
  269.        the mouse driver, so that your routine is automatically called when
  270.        certain mouse events take place.  Just be sure that your procedure is
  271.        declared as a far call, and pass its address to tmTask, along with a
  272.        mask telling it what events to branch on.  Please see the example
  273.        mouse event handler in MouseMenu for other information.
  274.  
  275.          The mask is made up of these bits:
  276.  
  277.             Bit 0      Movement
  278.             Bit 1      Left Button Press
  279.             Bit 2      Left Button Release
  280.             Bit 3      Right Button Press
  281.             Bit 4      Right Button Release
  282.             Bit 5      Middle Button Press
  283.             Bit 6      Middle Button Release
  284.  
  285.        The data returned from the mouse event handler is as follows:
  286.  
  287.          Register AX  --  The event that occured (in a bit set)
  288.          Register BX  --  Current button status (as in tmPos)
  289.          Register CX  --  Column Position
  290.          Register DX  --  Row Position
  291.  
  292.  
  293.     Procedure tmPen(Pen: Boolean);                          Function 13 and 14
  294.  
  295.        You may never have a use for this routine, but it has been provided for
  296.        you.  When you reset the mouse, light pen emulation is set to ON by
  297.        default.  When light pen emulation is on, the mouse cursor's position is
  298.        taken as the light pen's position.  If your program uses a light pen for
  299.        input, be sure you use tmPen(False) to turn the mouse driver's light pen
  300.        emulation off.
  301.  
  302.  
  303.     See the two example Turbo Pascal programs, MouseDraw and MouseText,  for
  304.     detailed information and example programs involving the routines in
  305.     TheMouse.  MouseDraw demonstrates the mouse routines in a graphics drawing
  306.     program (CGA required), and MouseText uses the routines in text mode.
  307.  
  308.  
  309.     If you make use of the routines in TheMouse, please register.  You have 30
  310.     days to examine TheMouse, and if you are satisfied with it, then please
  311.     send $10 to me at the address on the first page of documentation.  To thank
  312.     you for your registration, I'll send you the TheMouse Icon Editor which you
  313.     can use to create icons for use with TheMouse.  If you'd like the source
  314.     code to TheMouse and the Icon Editor, then please send an additional $25.
  315.  
  316.     I hope you enjoy and make use of these routines!
  317.  
  318.  
  319.                                                ..Kevin Kwast
  320.  
  321.  
  322.          ----------------end-of-author's-documentation---------------
  323.  
  324.                          Software Library Information:
  325.  
  326.                     This disk copy provided as a service of
  327.  
  328.                            Public (software) Library
  329.  
  330.          We are not the authors of this program, nor are we associated
  331.          with the author in any way other than as a distributor of the
  332.          program in accordance with the author's terms of distribution.
  333.  
  334.          Please direct shareware payments and specific questions about
  335.          this program to the author of the program, whose name appears
  336.          elsewhere in  this documentation. If you have trouble getting
  337.          in touch with the author,  we will do whatever we can to help
  338.          you with your questions. All programs have been tested and do
  339.          run.  To report problems,  please use the form that is in the
  340.          file PROBLEM.DOC on many of our disks or in other written for-
  341.          mat with screen printouts, if possible.  PsL cannot debug pro-
  342.          programs over the telephone, though we can answer questions.
  343.  
  344.          Disks in the PsL are updated  monthly,  so if you did not get
  345.          this disk directly from the PsL, you should be aware that the
  346.          files in this set may no longer be the current versions. Also,
  347.          if you got this disk from another vendor and are having prob-
  348.          lems,  be aware that  some files may have become corrupted or
  349.          lost by that vendor. Get a current, working disk from PsL.
  350.  
  351.          For a copy of the latest monthly software library newsletter
  352.          and a list of the 3,000+ disks in the library, call or write
  353.  
  354.                            Public (software) Library
  355.                                P.O.Box 35705 - F
  356.                             Houston, TX 77235-5705
  357.  
  358.                                 1-800-2424-PSL
  359.                              MC/Visa/AmEx/Discover
  360.  
  361.                           Outside of U.S. or in Texas
  362.                           or for general information,
  363.                               Call 1-713-524-6394
  364.  
  365.                           PsL also has an outstanding
  366.                           catalog for the Macintosh.
  367.  
  368.